using System.Data;
using System.Data.SqlClient;
using VanTaiProperty;
namespace VanTaiData
{
    public class clsTMDepartmentController
    {
        private clsConnect cls = new clsConnect();

        #region[Get-Data]
        public DataTable BindGirdTMDepartment()
        {
            return cls.BindGridData("sp_TMDepartment");
        }
        public DataTable BindGirdTMDepartment_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TMDepartment_Detail_Edit", "@Id", id);
        }
        public DataTable BindGridMail(string id)
        {
            return cls.LayDuLieuParameter1("sp_sp_TMDepartment_GD", id);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMDepartment(clsTMDepartmentProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Department_Alias", data.Department_Alias);
            cls.AddParameter("@Department_Name", data.Department_Name);
            cls.AddParameter("@Department_Name_E", data.Department_Name_E);
            cls.AddParameter("@Department_Name_C", data.Department_Name_C);
            cls.AddParameter("@Department_Note", data.Department_Note);
            cls.AddParameter("@Department_Block_ID", data.Department_Block_ID);
            cls.AddParameter("@Department_Phone", data.Department_Phone);
            cls.AddParameter("@Department_Fax", data.Department_Fax);
            cls.AddParameter("@Department_Email", data.Department_Email);
            cls.AddParameter("@Department_Address", data.Department_Address);
            cls.AddParameter("@Department_Address_E", data.Department_Address_E);
            cls.AddParameter("@Department_Address_C", data.Department_Address_C);
            cls.AddParameter("@MaCha", data.MaCha);
            cls.ExecuteNonQuery("sp_TMDepartment_Insert");
            return true;
        }
        public bool UpdateTMDepartment(clsTMDepartmentProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Department_ID", data.Department_ID);
            cls.AddParameter("@Department_Alias", data.Department_Alias);
            cls.AddParameter("@Department_Name", data.Department_Name);
            cls.AddParameter("@Department_Name_E", data.Department_Name_E);
            cls.AddParameter("@Department_Name_C", data.Department_Name_C);
            cls.AddParameter("@Department_Note", data.Department_Note);
            cls.AddParameter("@Department_Block_ID", data.Department_Block_ID);
            cls.AddParameter("@Department_Phone", data.Department_Phone);
            cls.AddParameter("@Department_Fax", data.Department_Fax);
            cls.AddParameter("@Department_Email", data.Department_Email);
            cls.AddParameter("@Department_Address", data.Department_Address);
            cls.AddParameter("@Department_Address_E", data.Department_Address_E);
            cls.AddParameter("@Department_Address_C", data.Department_Address_C);
            cls.AddParameter("@MaCha", data.MaCha);
            cls.ExecuteNonQuery("sp_TMDepartment_Update");
            return true;
        }
        public bool DeleteTMDepartment(int id)
        {
            cls.Delete("sp_TMDepartment_Delete","@Department_ID", id);
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TMDepartment_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}